#include <algorithm>
#include <vector>
#include <string>
#include <iterator>
#include <iostream>

class Person {
	int m_age;
	std::string m_name;
public:
	Person(int age, const std::string& name) : m_age(age), m_name(name) {}
	bool operator<(const Person& rhs) { return m_age < rhs.m_age; }
	friend std::ostream& operator<< (std::ostream& os, const Person& p);
	friend class PersonComp;
};

std::ostream& operator<< (std::ostream& os, const Person& p){
	os << p.m_age << " " << p.m_name << std::endl;
	return os;
}

class PersonComp {
public:
	bool operator()(const Person& lhs, const Person& rhs) { return lhs.m_name.compare(rhs.m_name) <= 0; }
};

void test_sort(){
	Person a(28, "Liang Zhang");
	Person b(26, "Huajuan Chen");
	Person c(0, "Liu Liu");
	std::vector<Person> family;
	family.push_back(a);
	family.push_back(b);
	family.push_back(c);

	std::sort(family.begin(),family.end());
	for (Person m : family) {
		std::cout << m;
	}

	std::sort(family.begin(),family.end(),PersonComp());
	for (Person m : family) {
		std::cout << m;
	}
}